//
//  FKAddOtherLogisticsVC.m
//  WanTao
//
//  Created by Macbook Pro on 2019/4/3.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKAddOtherLogisticsVC.h"

@interface FKAddOtherLogisticsVC ()

@property (nonatomic, weak) UITextField *inputField;

@end

@implementation FKAddOtherLogisticsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"其他物流";
    
    [self fk_removeBeforeVC];
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 10, fkScreenW, fk_adjustW(48))];
    [self.view addSubview:container];
    container.backgroundColor = [UIColor whiteColor];
    
    UITextField *inputField = [[UITextField alloc] init];
    [container addSubview:inputField];
    self.inputField = inputField;
    inputField.placeholder = @"请输入物流名称";
    inputField.font = fk_adjustFont(14);
    
    UIButton *saveBtn = [UIButton fk_btnWithTarget:self action:@selector(saveBtnClicked) font:fk_adjustFont(16) normalTitle:@"保存" normalTitleColor:[UIColor whiteColor] selectedTitle:nil selectedTitleColor:nil normalImg:nil selectedImg:nil bgImg:[UIImage imageNamed:@"bg_main"] selectedBgImg:nil];
    [self.view addSubview:saveBtn];
    [saveBtn fk_viewCornerRadius:5 borderWidth:0 borderColor:nil];

    
    [inputField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.right.offset(-12);
        make.top.bottom.offset(0);
    }];
    [saveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(15);
        make.right.offset(-15);
        make.height.offset(fk_adjustW(44));
        make.top.equalTo(container.mas_bottom).offset(50);
    }];
}

- (void)saveBtnClicked
{
    if (self.inputField.text.length == 0) {
        [SVProgressHUD showInfoWithStatus:self.inputField.placeholder];
        return;
    }
    
    NSMutableDictionary *result = [NSMutableDictionary dictionaryWithDictionary:self.data];
    result[@"name"] = self.inputField.text;
    [[NSNotificationCenter defaultCenter] postNotificationName:@"addOtherLogistic" object:nil userInfo:result];
    fkPopVC;
}



@end
